import numpy as np
import torch
from skimage import io
from PIL import Image

# 读取两个图像
from data import loss

image_path1 = 'C:/Users/crxc/Pictures/wandb/1/fixed.png'  # 更改为你的图像路径
image_path2 = 'C:/Users/crxc/Pictures/wandb/1/moving.png'  # 更改为你的图像路径

image1 = io.imread(image_path1, as_gray=True)
image2 = io.imread(image_path2, as_gray=True)

# 确保两个图像大小相同
image1 = torch.from_numpy(np.array(Image.fromarray(image1)))
image2 = torch.from_numpy(np.array(Image.fromarray(image2)))
tensor_image1 = image1.to("cuda:0")*2-1
tensor_image2 = image2.to("cuda:0")*2-1

NCC = loss.NCC()
ncc_score = NCC(tensor_image1, tensor_image1)
# SSIM = loss.SSIM()
# ssim_score = SSIM(tensor_image1, tensor_image1)

print(f'NCC Score: {ncc_score}')
# print(f'SSIM Score: {ssim_score}')